<script lang="ts" setup>
import { ref } from 'vue'
const { disabled } = defineProps<{ disabled?: boolean }>()
const showPopover = ref(false)
// 通过 actions 属性来定义菜单选项
const actions = [{ text: '查看处方', disabled }, { text: '删除订单' }]
const emit = defineEmits<{
  (e: 'on-preview'): void
  (e: 'on-delete'): void
}>()
const onSelect = (action: any, i: number) => {
  if (i === 0) {
    // 通知父组件
    emit('on-preview')
  }
  if (i === 1) {
    // 通知父组件
    emit('on-delete')
  }
}
</script>

<template>
  <div class="more">
    <van-popover
      v-model:show="showPopover"
      :actions="actions"
      @select="onSelect"
      placement="top-start"
    >
      <template #reference> 更多 </template>
    </van-popover>
  </div>
</template>

<style scoped>
.more {
  color: var(--cp-tag);
  flex: 1;
  font-size: 13px;
}
</style>
